package com.hfi.alibaba;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ChangLiang
 * @date 2018/8/24
 */
public class ListForeachTest {

    @Test
    public void listRemove() {
        List<String> list = new ArrayList<>();
        list.add("1");
        list.add("2");
        for (String item :
                list) {
            if ("1".equals(item)) {
                list.remove(item);
            }
        }
        System.out.println(list);
    }

    @Test
    public void listRemove2() {
        List<String> list = new ArrayList<>();
        list.add("1");
        list.add("2");
        for (String item :
                list) {
            if ("2".equals(item)) {
                list.remove(item);
            }
        }
        System.out.println(list);
    }
}
